import tpl from './index.tpl'
import './index.scss'

import { tplReplace } from '../../../utils/tools'

export default () => {
  return {
	name: 'page',
	tpl (dataItem) {
	  const oPage = document.createElement('div'), pageHTML = this.renderPage(dataItem)

	  oPage.className = 'page'
	  oPage.innerHTML = pageHTML

	  return {
		oPage,
		pageHTML
	  }
	},

	renderPage (dataItem) {
	  return tplReplace(tpl, {
		city_name: dataItem.city_name,
		img: dataItem.img,
		intro: dataItem.intro
	  })
	}
  }
}